/* 
 * File:   Box.h
 * Author: eliana
 *
 * Created on May 18, 2012, 9:17 PM
 */

#ifndef BOX_H
#define	BOX_H

#include "Material.h"
#include "Vector4D.h"
#include "Ray.h"
#include "Object.h"

/**
 * Represents an AAB ( Axis Aligned Box )
 */
class Box : public Object
{
public:
    
    /**
     * Constructor
     * @param min Minimum values of x, y and z
     * @param max Maximum values of x, y and z
     */
    Box( Vector4D min, Vector4D max );
    
    /**
     * Destructor
     */
    virtual ~Box();
    
    /**
     * From Object interface:
     * Computes the intersection of the object with the given ray
     * @param ray Ray that may intersect the object
     * @param t Parameter of the ray, indicating how far from the ray origin is 
     *          the intersection
     * @return true if intersects, false otherwise
     */
    bool computeRayIntersection( Ray& ray, double& t );
    
    /**
     * From Object interface:
     * Gives the Normal vector of the object at a given point.
     * If the point is not in the object's surface, returns null vector (0,0,0,1)
     * @param point Point in the object's surface
     * @return the Normal vector of the object
     */
    Vector4D getNormal( Vector4D& point );
    
    /**
     * From Object interface:
     * Sets the id of the object's material.
     * All the materials are stored in the Scene class.
     * @param materialId Id of the material
     */
    void setMaterial( int materialId );
    
    /**
     * From Object interface:
     * @return The Id of the object's material
     */
    int getMaterialId();
    
    /**
     * From Object interface:
     * @return The type of the object
     */
    ObjectType getType();
    
    /**
     * From Object interface:
     * Gives access to the min and maximum values of the axis aligned bounding 
     * box of the object
     * @param min Minimum values of the aabb
     * @param max Maximum values of the aabb
     */
    void getBoundingBox( Vector4D& min, Vector4D& max );
    
    /**
     * @return Vector with the minimum x, y and z coordinates
     */
    Vector4D getMin();
    
    /**
     * @return Vector with the maximum x, y and z coordinates
     */
    Vector4D getMax();
    
private:

    /** Id of the material */
    int _materialId;
    
    /** Vector with the minimum x, y and z coordinates */
    Vector4D _min;
    
    /** Vector with the maximum x, y and z coordinates */
    Vector4D _max;
};

#endif	/* BOX_H */

